<template>
  <page-header-wrapper>
    <a-card :bordered="false">
      <div class="table-page-search-wrapper">
        <a-form layout="inline" :label-col="labelCol" :wrapper-col="wrapperCol" labelAlign="left" :form="form">
          <a-row :gutter="48">

            <template v-if="!advanced">
              <a-col :md="8" :sm="24">
                <a-form-item label="操作模块 ">
                  <a-input  placeholder="" v-model="search" />
                </a-form-item>
              </a-col>
            </template>

            <!--            <template v-if="advanced">-->
            <!--              <a-col :md="8" :sm="24">-->
            <!--                <a-form-item label="补丁编号:">-->
            <!--                  <a-input placeholder="请输入" v-decorator="['patchNo']"/>-->
            <!--                </a-form-item>-->
            <!--              </a-col>-->
            <!--              <a-col :md="8" :sm="24">-->
            <!--                <a-form-item label="补丁描述:">-->
            <!--                  <a-input placeholder="" v-decorator="['abs']"/>-->
            <!--                </a-form-item>-->
            <!--              </a-col>-->
            <!--              <a-col :md="8" :sm="24">-->
            <!--                <a-form-item label="危险等级:">-->
            <!--                  <a-select  placeholder="请选择" v-decorator="['dangerLv']">-->
            <!--                    <a-select-option value="">全部</a-select-option>-->
            <!--                    <a-select-option v-for="item in DangerLevel" :value="item.value">{{item.label}}</a-select-option>-->
            <!--                  </a-select>-->
            <!--                </a-form-item>-->
            <!--              </a-col>-->
            <!--              <a-col :md="8" :sm="24">-->
            <!--                <a-form-item label="操作系统:">-->
            <!--                  <a-select  placeholder="请选择" v-decorator="['adaptationOs']">-->
            <!--                    <a-select-option value="">全部</a-select-option>-->
            <!--                    <a-select-option v-for="item in Ostype" :value="item.value">{{item.label}}</a-select-option>-->
            <!--                  </a-select>-->
            <!--                </a-form-item>-->
            <!--              </a-col>-->
            <!--              <a-col :md="8" :sm="24">-->
            <!--                <a-form-item label="补丁类型:">-->
            <!--                  <a-select  placeholder="请选择" v-decorator="['patchTypes']">-->
            <!--                    <a-select-option value="">全部</a-select-option>-->
            <!--                    <a-select-option v-for="item in PatchType" :value="item.value">{{item.label}}</a-select-option>-->
            <!--                  </a-select>-->
            <!--                </a-form-item>-->
            <!--              </a-col>-->


            <!--              <a-col :md="8" :sm="24">-->
            <!--                <a-form-item label="发布时间:">-->
            <!--                  <a-date-picker  v-decorator="['publishingTime']" style="width: 100%;"/>-->
            <!--                </a-form-item>-->
            <!--              </a-col>-->
            <!--            </template>-->
            <a-col :md="(!advanced && 8) || 24" :sm="24">
                    <span
                      class="table-page-search-submitButtons"
                      :style="(advanced && { float: 'right', overflow: 'hidden' }) || {}"
                    >
                      <a-button type="primary" @click="searchlog()">查询</a-button>
<!--                      <a-button style="margin-left: 8px" @click="resetform()">重置</a-button>-->

                      <!--                      <a @click="toggleAdvanced" style="margin-left: 8px">-->
                      <!--                        {{ advanced ? '收起' : '展开' }}-->
                      <!--                        <a-icon :type="advanced ? 'up' : 'down'" />-->
                      <!--                      </a>-->
                    </span>
            </a-col>
          </a-row>
        </a-form>
      </div>

      <a-row>
        <a-table :columns="columns" :data-source="data"  :pagination="tablepagination"  @change="tablechange">
          <template slot="createTime" slot-scope="text, record">
            {{text?text.replace('T',' '):''}}
          </template>
        </a-table>
      </a-row>
    </a-card>
  </page-header-wrapper>
</template>

<script>
  import { getPolicylist } from '@/api/log'

  export default {
    name: 'policy',
    data(){
      return{
        search:'',
        labelCol: {
          xs: { span: 24 },
          sm: { span: 6 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 12 },
        },
        advanced:false,
        tablepagination:{
          showTotal:(total, range) => {return `共搜索到${total}条数据`},
          current:1,
          total:0
        },
        form:this.$form.createForm(this, { name: 'plog' }),
        columns:[
          {
            title: '操作方法',
            dataIndex: 'method',
            key: 'method',
            width: 100
          },
          {
            title: '操作内容',
            dataIndex: 'content',
            key: 'content',
            width: 100
          },
          {
            title: '参数',
            dataIndex: 'operRequParam',
            key: 'operRequParam',
            width: 200
          },
          {
            title: '操作人',
            dataIndex: 'operUserName',
            key: 'operUserName',
            width: 100
          },
          {
            title: '操作接口',
            dataIndex: 'operUri',
            key: 'operUri',
            width: 100
          },

          {
            title: '访问时间',
            dataIndex: 'createTime',
            key: 'createTime',
            width:150,
            scopedSlots: { customRender: 'createTime' },
          },

        ],
        data:[],
      }
    },
    mounted() {
      this.getlist()
    },
    methods:{
      getlist(){
        let params = {}
        params.operModul = ''
        params.pageNo = this.tablepagination.current-1
        params.pageSize = 10
        params.search = this.search
        getPolicylist(params).then(res=>{
          let record = res.data.records
          for(let i in record){
            record[i].key =record[i].id
          }
          this.data = record
          this.tablepagination.total = res.data.total
        })
      },
      tablechange(pagination){
        this.tablepagination = pagination
        this.getlist()
      },
      toggleAdvanced() {
        this.advanced = !this.advanced
      },
      searchlog(){
        this.tablepagination.current = 1
        this.getlist()
      }
    }
  }
</script>

<style scoped>

</style>